package tum0r.server.problem.misc.steganography;

import tum0r.model.ProblemInfoItem;
import tum0r.model.ProblemLevel;
import tum0r.server.problem.ProblemBase;
import tum0r.webengine.annotation.Server;
import tum0r.webengine.model.server.EngineFile;
import tum0r.webengine.utils.server.action.Action;

import java.io.IOException;

/**
 * 工程: Security<br>
 * 包: tum0r.server.problem.misc.steganography<br>
 * 创建者: tum0r<br>
 * 创建时间: 2021/3/22 11:30<br>
 * <br>
 */
@Server(Mapping = "/security/problem/misc/steganography/picture1")
public class Picture1 extends ProblemBase {
    public Picture1() {
        information.ProblemTitle = "图片隐写1";
        information.ProblemID = 8;
        information.Creator = "tum0r";
        information.ProblemLevel = ProblemLevel.Entry;
        information.CreateTime = "2020/03/22";
        ProblemInfoItem problem = new ProblemInfoItem("problem", null);
        information.ProblemInfo.add(problem);
    }

    @Override
    public void description(Action<String> action) {
        action.callBack("你看不见我你看不见我");
    }

    @Override
    public void tips(Action<String> action) {
        action.callBack("这是一个被施了幻身咒的图片，反咒是人形显身");
    }

    @Override
    public void writeUp(Action<String> action) {
        action.callBack("""
                0、幻身咒可以把被施加物体变成如变色龙一般，在图片上就是Alpha值变为0了
                                
                1、写脚本把图片所有像素的Alpha设置为255，然后扫码
                                
                2、Base64解码3次，拿到flag
                """);
    }

    public void problem(Action<EngineFile> action) throws IOException, InterruptedException {
        EngineFile result = new EngineFile();
        result.read("Files/code_6.png");
        action.callBack(result);
    }
}
